package test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

/**
 * @ClassName T1
 * @Description
 * @Author Jingxiao.Ye
 * @Date 2021/8/8 下午5:09
 * @Version V1.0
 * @Since JDK 11
 */
public class T1 {

    public static void main(String[] args) {
        System.out.println(filterRestaurants(new int[][]{new int[]{1, 4, 1, 40, 10}, new int[]{2, 8, 0, 50, 5}}, new int[]{1, 40, 10}));
    }

    public static int[] filterRestaurants(int[][] restaurants, int[] filters) {
        int count = 0;
        for (int i = 0; i < restaurants.length; i++) {
            if (!((filters[0] ==0 || restaurants[i][2] == 1) && restaurants[i][3] <= filters[1]
                    && restaurants[i][4] <= filters[2])) {
                restaurants[i] = null;
                count++;
            }
        }
        Arrays.sort(restaurants,(a,b)->{
            if(a == null){
                //最小的
                return 1;
            }
            if(b == null){
                return -1;
            }
            return b[1] -a[1]== 0?b[0] -a[0]:b[1] -a[1];
        });
        int[] res =new int [restaurants.length-count];
        for (int i = 0; i < res.length; i++) {
            res[i] = restaurants[i][0];
        }
        return res;
    }
}
